package com.aaa.entity;

import lombok.Data;

@Data
public class R {
    private Integer code;
    private String msg;
    private Boolean success;
    private Object entity;

    private R() {
    }

    public static R ok() {
        R r = new R();
        r.setCode(200);
        r.setSuccess(true);
        return r;
    }

    public static R error() {
        R r = new R();
        r.setCode(-1);
        r.setSuccess(false);
        return r;
    }

    public static R ok(Object res) {
        return ok().entity(res);
    }

    public R entity(Object res) {
        this.entity = res;
        return this;
    }

    public R message(String message) {
        this.msg = message;
        return this;
    }

    public R code(Integer code) {
        this.code = code;
        return this;
    }
}
